package com.qfedu.meidijiaju.controller;


import com.qfedu.meidijiaju.common.ResponseData;
import com.qfedu.meidijiaju.entity.PinglunYxy;
import com.qfedu.meidijiaju.service.PinglunYxyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author meidimeiju
 * @since 2022-10-04
 */
@Api(tags = "发现帖子评论相关小模块")
@RestController
@RequestMapping("/meidijiaju/pinglun-yxy")
public class PinglunYxyController {

    @Autowired
    private PinglunYxyService pinglunYxyService;

    @ApiOperation(value = "/根据帖子对应id 查询 对应的帖子下评论信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tieziId",value = "对应的帖子id",paramType = "query",dataType = "int")
    })
    @RequestMapping(value = "/queryPingLunByTieZiId",method = RequestMethod.GET)
    public ResponseData<List<PinglunYxy>> queryPingLunByTieZiId(int tieziId){

        return pinglunYxyService.findPinglun(tieziId);
    }

    @ApiOperation(value = "/为当前用户添加对应帖子的评论,需要获取当前用户id和对应的帖子id以及评论内容")
    @RequestMapping(value = "/addPingLun",method = RequestMethod.POST)
    public ResponseData<String> addPingLun(PinglunYxy pinglunYxy){

        return pinglunYxyService.addPingLun(pinglunYxy);
    }

}

